package com.koron.css2.baseConfig.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.baseConfig.bean.ProcessTimeBean;
import com.koron.css2.baseConfig.mapper.ProcessTimeMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.util.Constant;
import com.koron.util.JsonUtils;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

public class ProcessTimeDelete implements ServerInterface{

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		// TODO Auto-generated method stub
		try {
			ProcessTimeBean bean = JsonUtils.objectToPojo(req.getData(),ProcessTimeBean.class);
			ProcessTimeMapper mapper = factory.getMapper(ProcessTimeMapper.class);
			ProcessTimeBean timeBean = mapper.query(bean.getId());
			mapper.delete(bean);
			mapper.deleteRecord(timeBean);
		}catch(Exception e){
			logger.error("操作失败", e);
			return MessageBean.create(Constant.MESSAGE_INT_FAIL, "操作失败", void.class);
		}
		return MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", void.class);
	}

}
